using System.Web.UI;

namespace BilSimser.SharePoint.Common.Controls
{
	public class OWSBooleanField : OWSBase
	{
		#region Construction

		/// <summary>
		/// default constructor
		/// </summary>
		public OWSBooleanField()
		{
		}

		#endregion

		#region overridden properties

		/// <summary>
		/// Gets "Yes" for true value "No" for false value.
		/// </summary>
		public override string Text
		{
			get { return (Value == "1") ? "Yes" : "No"; }
		}

		#endregion

		#region overridden methods

		/// <summary>
		/// Renders the contents of the controls
		/// </summary>
		/// <param name="wtr">the HTML write to which to output.</param>
		protected override void Render (HtmlTextWriter wtr)
		{
			wtr.Write(
				"<SCRIPT>" +
					"fld = new BooleanField(frm, \"{0}\", \"{1}\", \"{2}\"); " +
					"fld.IMEMode=\"inactive\"; " +
					"fld.BuildUI();" +
					"</SCRIPT>",
				UniqueID,
				Display,
				JavaScriptValue,
				Required.ToString().ToLower()
				);
		}

		#endregion
	}
}